package org.aceor.mddal.common.sqlparser.result.context;

import com.google.common.base.Objects;
import com.google.common.collect.Sets;
import org.aceor.mddal.common.sqlparser.result.SQLBuilder;
import org.aceor.mddal.common.sqlparser.result.object.SQLStatementType;
import org.aceor.mddal.common.sqlparser.result.object.Table;

import java.util.Set;

/**
 * Created by lxue on 16/3/23.
 */
public class RouteContext {
    /**
     * 解析时添加
     */
    private Set<Table> tables = Sets.newHashSet();
    /**
     * SQLParserEngine#parse时设置
     */
    private SQLBuilder sqlBuilder = new SQLBuilder();
    /**
     * SQLParserEngine#parse时设置
     */
    private SQLStatementType sqlStatementType;

    public Set<Table> getTables() {
        return tables;
    }

    public SQLBuilder getSqlBuilder() {
        return sqlBuilder;
    }

    public SQLStatementType getSqlStatementType() {
        return sqlStatementType;
    }

    public void setSqlStatementType(SQLStatementType sqlStatementType) {
        this.sqlStatementType = sqlStatementType;
    }

    public void setSqlBuilder(SQLBuilder sqlBuilder) {
        this.sqlBuilder = sqlBuilder;
    }

    @Override
    public String toString() {
        return Objects.toStringHelper(this)
                .add("Tables", tables)
                .add("SqlBuilder", sqlBuilder.toSQL())
                .add("SqlStatementType", sqlStatementType)
                .toString();
    }
}
